// Copyright (C)  , Tencent. All rights reserved.

package config

import (
	"gopkg.in/yaml.v2"
	"io/ioutil"
)

// SystemConfig 系统配置
var SystemConfig *Config

type MysqlConfig struct {
	Ip       string `yaml:"ip"`
	Port     string `yaml:"port"`
	User     string `yaml:"user"`
	Passwd   string `yaml:"pwd"`
	Database string `yaml:"database"`
}

type Config struct {
	MysqlConfig MysqlConfig `yaml:"mysql_config"`
}

func ReadConfig(path string) error {
	buffer, err := ioutil.ReadFile(path)
	if err != nil {
		return err
	}
	SystemConfig = &Config{}
	err = yaml.Unmarshal(buffer, SystemConfig)
	return err
}
